package net.huashitong.supervision.task.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.task.entity.TaskMainDraft;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * Created with IntelliJ IDEA.
 *
 * @author ling
 * @date: 2020/2/7
 * @time: 10:41
 * @version: 1.0
 * @Description:
 */
@Repository
public class TaskMainDraftDao extends StringDao<TaskMainDraft> {
    public List<TaskMainDraft> queryDraftList(TaskMainDraft taskMainDraft){
        GenericQuery obj = createQuery("obj");
        obj.append(" and userId =:userId").setParam("userId",taskMainDraft.getUserId());
        if (StringUtils.isNotBlank(taskMainDraft.getMainName())){
            obj.append(" and mainName like:mainName").setParam("mainName",StringUtils.getLikewords(taskMainDraft.getMainName()));
        }
        if (StringUtils.isNotBlank(taskMainDraft.getCategoryId())){
            obj.append(" and categoryId =:categoryId").setParam("categoryId",taskMainDraft.getCategoryId());
        }
        if (StringUtils.isNotBlank(taskMainDraft.getContent())){
            obj.append(" and content like:content").setParam("content",StringUtils.getLikewords(taskMainDraft.getContent()));
        }
        return obj.listResult();
    }
}
